package com.dnui.seven2.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dnui.seven2.common.BaseContext;
import com.dnui.seven2.common.R;
import com.dnui.seven2.entity.Buyshow;
import com.dnui.seven2.service.BuyshowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

@CrossOrigin
@Slf4j
@RestController
@RequestMapping("/buyShow")
public class BuyShowController {

    @Autowired
    private BuyshowService buyshowService;

    /**
     * 添加购物车
     * @param buyshow
     * @return
     */
    @PostMapping("/add")
    public R<String> add(@RequestBody Buyshow buyshow){
        buyshow.setBuyshowTime(LocalDateTime.now());
        buyshowService.save(buyshow);


        return R.success("成功");
    }

    /**
     * 查看购物车
     * @return
     */
    @GetMapping("/list")
    public R<List<Buyshow>> list(){
        log.info("查看购物车...");

        List<Buyshow> buyshows = buyshowService.selectAll();

        return R.success(buyshows);
    }

    /**
     * 清空购物车
     * @return
     */

}
